package network;

import lib.XmlPullParser;
import android.annotation.SuppressLint;

@SuppressLint("UseValueOf")
public class ParseXMLProvider {

	int requestResult = 0;
	int actionResult = 0;
	int typeXML;
	Object data;

	public ParseXMLProvider() {
	}

	public ParseXMLProvider(Object data) {
		this.data = data;
	}

	public int parseSetPublicKey(XmlPullParser xml) throws Exception {
		while ((typeXML = xml.next()) != XmlPullParser.END_DOCUMENT) {
			if (typeXML == XmlPullParser.START_TAG
					&& "response".equals(xml.getName())) {
				requestResult = Integer.parseInt(xml
						.getAttributeValue("result"));

				// System.out.println("requestResult" + requestResult);
				if (requestResult != 0) {
					// throw new Exception("" + requestResult);
					return requestResult;
				}
			} else if (typeXML == XmlPullParser.START_TAG
					&& "setPublicKey".equals(xml.getName())) {
				xml.next();
				return Integer.parseInt(xml.getAttributeValue("result"));
			}
		}
		return -1;
	}
}
